package com.qfedu.controller;

import com.qfedu.service.ManagerService;
import com.qfedu.service.impl.ManagerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @version v1.0
 * @Date 2023/10/9 18:15
 * @Author DARKER
 * @Email 1402216045@qq.com
 */
@WebServlet("/managers/del.do")
public class ManagerDelController extends HttpServlet {
    private ManagerService service = new ManagerServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/xml;charset=utf-8");
        resp.setCharacterEncoding("utf-8");
        Integer id = Integer.valueOf(req.getParameter("id"));
        try {
            service.del(id);
            resp.getWriter().write("删除成功!!!");
        }catch (Exception e){
            resp.getWriter().write("删除失败!!!");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
